using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Mnuemonix {

    public class ScreenSize {
        int width;
        int height;

        public ScreenSize(int height, int width)
        {
            this.height = height;
            this.width = width;
        }

        public int ScreenWidth
        {
            get { return width; }
            set { this.width = value; }
        }

        public int ScreenHeight
        {
            get { return height; }
            set { this.height = value; }
        }
    }

    public class Game1 : Microsoft.Xna.Framework.Game {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        public List<Word> wordList = new List<Word>();
        InputReader reader;
        private InputHandler input;

        //Screen Dimensions
        double screenSafePercent = .80;
        int screenHeight;
        int screenWidth;

        //Screens
        private ScreenManager screenManager;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            ScreenSize(screenSafePercent);
            graphics.PreferredBackBufferHeight = screenHeight;
            graphics.PreferredBackBufferWidth = screenWidth;

            this.input = new InputHandler(this);
            this.Components.Add(input);

            Content.RootDirectory = "Content";
        }

        public void ScreenSize(double percent)
        {
            screenHeight = Convert.ToInt32(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height * percent);
            screenWidth = Convert.ToInt32(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width * percent);
        }

        protected override void Initialize()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            reader = new InputReader();
            reader.ReadFromFile("WordFileA", wordList);     
            this.screenManager = new ScreenManager(this, spriteBatch);
            this.screenManager.addScreen(new MainMenuScreen(this.screenManager.Game, new ScreenSize(screenHeight, screenWidth), wordList));

            this.Components.Add(this.screenManager);
            base.Initialize();
        }

        protected override void LoadContent()
        {
            //reader.ReadFromFile("WordFileA", wordList);     
            //screenManager.addScreen(new DefinitionScreen(this.screenManager.Game, new ScreenSize(screenHeight, screenWidth), wordList)); //TODO: this will be menu screen
            //Components.Add(this.screenManager);
        }

        protected override void UnloadContent() { }

        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
        }
    }
}
